﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using XProject.DataVisit.Factory;
using XProject.DataVisit.Model;

namespace XProject.DataVisit.Handler.View.BaseManager
{
    public class MainView:AbstractView
    {
        private UserInfo CurrentUser;
        public override void init()
        {
            if (HttpContext.Current.Session["UserInfo"] != null)
            {
                CurrentUser=HttpContext.Current.Session["UserInfo"] as UserInfo;
                base.init();
            }
            else
            {
                return;
            }
        }

        public void CheckUserLogin()
        {
            if (DaoFactory.UserInfoDao.GetByNameAndPass_NoMD5(CurrentUser.UserAccount, CurrentUser.UserPass) != null)
            {
                JsonResponse.ResponseObject = "L";
            }
            else
            {
                JsonResponse.ResponseObject = "F";
            }
        }

        public void GetHeader()
        {
            JsonResponse.ResponseObject = CurrentUser.UserName + "|" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }

        public void ExitSystem()
        {
            HttpContext.Current.Session.Remove("UserInfo");
            JsonResponse.HasError  = false;
        }
    }
}
